import { request_login } from '@/utils/http'
import store from '@/store'

export function checkUser(next) {
  if (store.state.userInfo) {
    next()
  } else {
    request_login({
      url: "/emstu/teacher/checkuser"
    }).then(res => {

      if (res.data.code === 1) {
        store.commit('saveUserInfo', res.data.UseInfo)
        next()
        return
      }
      next('/login')
    });
  }
}
